/* Copyright (c) 2011 Team A CS2340. All rights reserved.*/

package edu.gatech.teama.doctorsoffice.net;

import edu.gatech.teama.doctorsoffice.model.Appointment;
import edu.gatech.teama.doctorsoffice.model.Patient;
import edu.gatech.teama.doctorsoffice.server.DataModel;

/**
 * Add Appointment
 * @author Team A
 * @version $Revision: 1.0 $
 *
 */
public class AddAppointmentMessage extends Message {

	/**
	 * Patient the appointment is for
	 */
	private final Patient patient;

	/**
	 * Appointment to add
	 */
	private final Appointment appointment;
	
	/**
	 * Add appointment
	 * @param patient patient to add appointment for
	 * @param appointment appointment to add
	 */
	public AddAppointmentMessage(Patient patient, Appointment appointment) {
		super(new Object[]{patient, appointment});
		
		this.patient = patient;
		this.appointment = appointment;
	}
	
	@Override // $codepro.audit.disable methodJavadoc
	public Message handle(DataModel model) {
		model.addAppointment(patient, appointment);
		return new SuccessMessage(true);
	}
	
	@Override public String toString() { // $codepro.audit.disable methodJavadoc
		return patient.toString() + " " + appointment.toString();
	}

}
